<?php
namespace app\admin\controller;
use \think\Controller;
use \think\Request;
use \think\facade\Session;

/*询问数据*/
class Subscribe extends Base{

	/*列表*/
	public function index(Request $request){
		$this->check_session();
        /*左侧导航*/
        $data_get=$request->get()['nav'];

        $data=$this->navleft($data_get);

        $this->assign($data);

	    return $this->fetch();
	}

	public function get_data(Request $request){
		$this->check_session();
        $get=$request->get();
        
        $model=new \app\admin\model\Subscribe ();/*调用模型查询*/
        $model_data=$model->get_data($get['page'],$get['limit']);
      

        
        $result=["code"=>0,'msg'=>"","count"=>$model_data['count'],"data"=>$model_data['list']];
        return json($result);
       
	}


 

    /*删除*/
	public function del(Request $request){
		$this->check_session();
		$data=$request->post();
		if(empty($data['id'])){
			$result=['status'=>'0','msg'=>'操作有误'];
	        return json($result);
		}
		$model=new \app\admin\model\Subscribe ();/*调用模型查询*/
        $model_data=$model->delete_data($data['id']);
		if($model_data!=1){
			$result=['status'=>'0','msg'=>'删除失败'];
	        return json($result);
		}else{
			$result=['status'=>'1','msg'=>'删除成功'];
	        return json($result);
		}
	}

	/*查询路径和留言信息*/
	public function get_one_data(Request $request){
		$this->check_session();
		$data=$request->post();
		if(empty($data['id'])){
			$result=['status'=>'0','msg'=>'操作有误'];
	        return json($result);
		}
		$model=new \app\admin\model\Subscribe ();/*调用模型查询*/
        $model_data=$model->get_one_data($data['id']);
        $result=['lasturl'=>$model_data['lasturl'],'nowurl'=>$model_data['nowurl'],'comments'=>$model_data['comments']];
		return json($result);
	}

}

